<?
    final class Principio_Model_CompanyInPool extends Principio_Model_Company
    {
        private $pool_id;
        private $model_pool;


        public function __construct(array $values = null)
        {
            parent::__construct($values);

            $this->type = self::TYPE_COMPANY_IN_POOL;
            $this->model_pool = null;

            $this->pool_id = (is_null($values) ? -1 : intval($values['pool_id']));
        }


        public function getDefaultGw() { return $this->getModelPool()->getDefaultGW(); }
        public function getNetmask() { return $this->getModelPool()->getNetmask(); }
        public function getNetname() { return $this->getModelPool()->getNetname(); }
        public function getBroadcast() { return $this->getModelPool()->getBroadcast(); }
        public function getRangeTo() { return $this->getModelPool()->getRangeTo(); }
        public function getRangeFrom() { return $this->getModelPool()->getRangeFrom(); }
        public function getIP() { return $this->getModelPool()->getIP();  }
        public function getVlanID() { return $this->getModelPool()->getVlanID(); }
        public function getVlanPcID() { return $this->getModelPool()->getVlanPcID(); }


        public function setDefaultGw($default_gw) { throw new RuntimeException("ComanyInPool doesn't allow Default GW."); }
        public function setNetmask($netmask) { throw new RuntimeException("ComanyInPool doesn't allow Netmask."); }
        public function setNetname($netname) { throw new RuntimeException("ComanyInPool doesn't allow Netname."); }
        public function setBroadcast($broadcast) { throw new RuntimeException("ComanyInPool doesn't allow Broadcast."); }
        public function setRangeTo($range_to) { throw new RuntimeException("ComanyInPool doesn't allow Range To."); }
        public function setRangeFrom($range_from) { throw new RuntimeException("ComanyInPool doesn't allow Range From."); }
        public function setIP($IP) { throw new RuntimeException("ComanyInPool doesn't allow IP.");  }


        public function isPool() { return false; }
        public function isCompanyInPool() { return true; }
        public function isCompany() { return false; }


        public function getModelPool()
        {
            if (is_null($this->model_pool))
                $this->model_pool = Principio_Model_PoolMapper::fetch($this->pool_id);

            return $this->model_pool;
        }


        public function setModelPool(Principio_Model_Pool $model_pool)
        {
            $this->model_pool = $model_pool;
            $this->pool_id = $model_pool->getID();
        }


        public function add() { return Principio_Model_CompanyInPoolMapper::save($this); }
        public function save() { return Principio_Model_CompanyInPoolMapper::save($this); }
    }
?>